#include "stdafx.h"
#include "../Signal2.h"
#include "../../UnitTest/TestMgr.h"
#include "../../UnitTest/Test.h"

using namespace patiya::Sig;

namespace {

    class ObjectA : public SigSender<ObjectA, Object> {
    public: 
        ObjectA() {
        }
        ~ObjectA() {
        }
        void sendSig(Signal* pSignal) {            
            notify(&ObjectA::sendSig, pSignal);
        }
        void foo() {
            Signal signal;
            sendSig(&signal);
        }
    };

    class ObjectB : public SigSender<ObjectB, Object> {
    public:
        void receiveSig(Signal*) {
            std::cout << "ObjectB::receiveSig" << std::endl;
        }
    };

    class ObjectC : public SigSender<ObjectC, Object> {
    public:
        void receiveSig(Signal*) {
            std::cout << "ObjectC::receiveSig" << std::endl;
        }
    };

}

void testSignal2()
{
    ObjectA objA;
    ObjectB objB;
    ObjectC objC;

    //objA.connect(&ObjectA::sendSig, &objB, &ObjectB::receiveSig);
    //objA.connect(&ObjectA::sendSig, &objC, &ObjectC::receiveSig);
    //objA.foo();

    //objA.disconnect(&ObjectA::sendSig, &objB, &ObjectB::receiveSig);
    //objA.disconnect(&ObjectA::sendSig, &objC, &ObjectC::receiveSig);
    //objA.foo();
}

static Base::UnitTest::Test kTestSignal(testSignal2);